#include "../unicode.cc"
// clang++ -std=c++11 unicode.cc -fsanitize=address -fno-omit-frame-pointer
// You need to pay attention to shell escape effects when testing.
// example: this unicode string has non bmp string --- ---\ 💖
int main(int argc, char const *argv[]) {
  if (argc < 3) {
    fprintf(stderr, "usage: %s command str\n", argv[0]);
    return 1;
  }
  if (strcmp(argv[1], "escape") == 0 || strcmp(argv[1], "e") == 0) {
    fprintf(stderr, "%s\n", gitee::EscapeUnicode(argv[2]).data());
    return 0;
  }
  if (strcmp(argv[1], "unescape") == 0 || strcmp(argv[1], "u") == 0) {
    std::string s;
    if (gitee::UnescapeUnicode(argv[2], true, &s)) {
      fprintf(stderr, "%s\n", s.data());
      return 0;
    }
    fprintf(stderr, "\x1b[31munable unescape: %s\x1b[0m\n", argv[2]);
    return 1;
  }
  fprintf(stderr, "unsupport cmd: %s\n", argv[1]);
  return 0;
}
